<?php

class components {
    
    public $name;
    protected $page;
    protected $tag;
    public $value;
    protected $label;
    protected $style;
    
    public function __construct($name, $page, $tag = 'formContent', $settings = array()) {
        
        $this->name = $name;
        $this->page = $page;
        $this->tag = $tag;
        
        # Store settings
        if($settings != null) {
            foreach($settings as $setting => $value) {
                $this->$setting = $value;
            }
        }
        
    }
    
    public function beforeInit($page, $tag, $settings) {
        
        $this->componentPage = new templateEngine('defaultcomponent');
        $this->page = $page;
        $this->tag = $tag;
        
        foreach($settings as $attribute => $setting) {
            $this->$attribute = $setting;
        }
        
    }
    
    public function init() {
        
        $this->generate($this->page, $this->tag);
        
    }
    
    protected function generate($page, $tag) {
        
    }
    
//    public function __destruct() {
//        
//        # We keep this component in the session after use
//        $_SESSION[$this->name] = serialize($this);
//        
//    }
    
    
}

?>
